1 using System;
2 using System.Collections.Generic;
3 using System.ComponentModel;
4 using System.Data;
5 using System.Drawing;
6 using System.Linq;
7 using System.Text;
8 using System.Threading.Tasks;
9 using System.Windows.Forms;
10
11 namespace SoftQuanLyNhaHang.Views
12 {
13 public partial class frmKho_ThietLapGia : Form
14 {
15 public frmKho_ThietLapGia()
16 {
17 InitializeComponent();
18 }
19
20 private int _getIdKho;
21 private string _getMaSanPham;
22 private string _getMaVietTat;
23
24
25 bool txtClickTiLeLoiNhuan = true;
26 bool txtClickGiaBanLe = false;
27 bool loadlandau = true;
28
29 //int _tongSoBanGhi = 0;
30 //int _stt =0;
31 //int _pageSize = 30;
32 //int _pageIndex = 1;
33
34 private void frmKho_ThietLapGia_Load(object sender, EventArgs e)
35 {
36 // this.HienThi_Thue_ComboBox();
37
38 this.HienThiThongTinVaoForm();
39
40 this.ActiveControl = txtGiaBanLe;
41
42 // this.HienThiDanhSachGiaNhap();
43
44 /*
45 //tinh gia nhap trung binh
46 DataTable dtGiaNhapTb = new DataTable();
47
48 dtGiaNhapTb = Controllers.KhoCtrl.FillDataSet_GetSCac_SP_TonKho_ByMaSanPham(_getMaVietTat, 0, _getMaVietTat).Tables[0];
49
50 double _giaNhapTb = 0;
51 float _tongSoLuong = 0;
52
53 if (dtGiaNhapTb.Rows.Count > 0)
54 {
55
56 double _giaNhap = 0;
57 float _soLuongNhap = 0;
58 //float _soLuongDaBan = 0;
59
60 double _thueNhap = 0;
61 double _chietKhauNhap = 0;
62
63 double _thanhTien = 0;
64 //float _soLuongTon = 0;
65
66 double _tongTien = 0;
67
68
69
70 foreach (DataRow item in dtGiaNhapTb.Rows)
71 {
72 _giaNhap = CauHinhHeThong.Format_SoDeTinhToan(item["GiaNhap"].ToString(), false);
73 _thueNhap = CauHinhHeThong.Format_SoDeTinhToan(item["Thue"].ToString(), false);
74 _chietKhauNhap = CauHinhHeThong.Format_SoDeTinhToan(item["ChietKhauPhanTram"].ToString(), false);
75
76 _soLuongNhap = (float)CauHinhHeThong.Format_SoDeTinhToan(item["SoLuong"].ToString(), false);
77 //_soLuongDaBan = (float)CauHinhHeThong.Format_SoDeTinhToan(item["SoLuongDaBan"].ToString(), false);
78
79 //_soLuongTon = _soLuongNhap - _soLuongDaBan;
80
81 _thanhTien = _giaNhap * _soLuongNhap - _giaNhap * _soLuongNhap * _chietKhauNhap / 100 + _giaNhap * _soLuongNhap * _thueNhap / 100;
82
83 _tongTien += _thanhTien;
84 _tongSoLuong += _soLuongNhap;
85
86
87 if (_tongSoLuong != 0)
88 {
89 _giaNhapTb = _tongTien / _tongSoLuong;
90 }
91
92
93 }
94 }
95 else
96 {
97 _giaNhapTb = 0;
98 }
99
100 txtGiaNhapTB.Text = CauHinhHeThong.Format_SoDeHienThi(_giaNhapTb, true);
101 txtSoLuongTon.Text = CauHinhHeThong.Format_SoDeHienThi(_tongSoLuong, false);
102 */
103 }
104
105 public frmKho_ThietLapGia(int idKho, string maSanPham, string maVietTat) : this()
106 {
107 _getIdKho = idKho;
108 _getMaSanPham = maSanPham;
109 _getMaVietTat = maVietTat;
110 }
111
112 /*
113 private void HienThi_Thue_ComboBox()
114 {
115 Dictionary<string, string> comboSource = new Dictionary<string, string>();
116
117 DataTable dtThue = new DataTable();
118 dtThue = Controllers.ThueCtrl.FillDataSetThue_GetShowDropdow().Tables[0];
119
120 if (dtThue.Rows.Count > 0)
121 {
122 foreach (DataRow item in dtThue.Rows)
123 {
124 comboSource.Add(item["Thue"].ToString(), item["Thue"].ToString());
125 }
126
127 }
128 cmbThueSuat.DataSource = new BindingSource(comboSource, null);
129 cmbThueSuat.DisplayMember = "Value";
130 cmbThueSuat.ValueMember = "Key";
131 }
132 */
133
134 private void HienThiThongTinVaoForm()
135 {
136
137 DataTable dtKho = new DataTable();
138
139 dtKho = Controllers.KhoCtrl.FillDataSet_getKho_ByIdKho(_getIdKho).Tables[0];
140 //dtKho = Controllers.KhoCtrl.FillDataSet_getKho_ByMaSanPham_MaVietTat(_getMaSanPham, -1, _getMaVietTat).Tables[0];
141
142 if (dtKho.Rows.Count > 0)
143 {
144
145 double thueN = 0;
146 double ckNhap = 0;
147 double gNhap = 0;
148
149 double tTienGiaNhap = 0;
150
151 //_getIdKho = Int32.Parse(item["IdKho"].ToString());
152 txtTenSanPham.Text = dtKho.Rows[0]["TenSanPham"].ToString();
153 txtMaSanPham.Text = dtKho.Rows[0]["MaSanPham"].ToString();
154 txtMaVietTat.Text = dtKho.Rows[0]["MaVietTat"].ToString();
155
156 gNhap = CauHinhHeThong.Format_SoDeTinhToan(dtKho.Rows[0]["GiaNhap"].ToString(), false);
157 thueN = CauHinhHeThong.Format_SoDeTinhToan(dtKho.Rows[0]["Thue"].ToString(), false);
158 ckNhap = CauHinhHeThong.Format_SoDeTinhToan(dtKho.Rows[0]["ChietKhauPhanTram"].ToString(), false);
159
160 tTienGiaNhap = gNhap - gNhap * ckNhap / 100 + gNhap * thueN / 100;
161 txtGiaNhap.Text = CauHinhHeThong.Format_SoDeHienThi(tTienGiaNhap, true);
162
163 txtTiLeLoiNhuan.Text = CauHinhHeThong.Format_SoDeHienThi(CauHinhHeThong.Format_SoDeTinhToan(dtKho.Rows[0]["TiLeLoiNhuan"].ToString(), false), false);
164 txtGiaBanLe.Text = CauHinhHeThong.Format_SoDeHienThi(CauHinhHeThong.Format_SoDeTinhToan(dtKho.Rows[0]["GiaBanLe"].ToString(), false), true);
165 txtGiaBanBuon.Text = CauHinhHeThong.Format_SoDeHienThi(CauHinhHeThong.Format_SoDeTinhToan(dtKho.Rows[0]["GiaBanBuon"].ToString(), false), true);
166 txtGiaKhuyenMai.Text = CauHinhHeThong.Format_SoDeHienThi(CauHinhHeThong.Format_SoDeTinhToan(dtKho.Rows[0]["GiaKhuyenMai"].ToString(), false), true);
167 // txtCKSuat.Text = CauHinhHeThong.Format_SoDeHienThi(CauHinhHeThong.Format_SoDeTinhToan(dtKho.Rows[0]["ChietKhauPTBanHang"].ToString(), false), false);
168 // cmbThueSuat.SelectedValue = dtKho.Rows[0]["ThueBanHang"].ToString();
169
170
171
172 /*
173 foreach (DataRow item in dtKho.Rows)
174 {
175 _getIdKho = Int32.Parse(item["IdKho"].ToString());
176 txtTenSanPham.Text = item["TenSanPham"].ToString();
177 txtMaSanPham.Text = item["MaSanPham"].ToString();
178 txtMaVietTat.Text = item["MaVietTat"].ToString();
179
180 gNhap = CauHinhHeThong.Format_SoDeTinhToan(item["GiaNhap"].ToString(), false);
181 thueN = CauHinhHeThong.Format_SoDeTinhToan(item["Thue"].ToString(), false);
182 ckNhap = CauHinhHeThong.Format_SoDeTinhToan(item["ChietKhauPhanTram"].ToString(), false);
183
184 tTienGiaNhap = gNhap - gNhap * ckNhap / 100 + gNhap * thueN / 100;
185
186 txtGiaNhap.Text = CauHinhHeThong.Format_SoDeHienThi(tTienGiaNhap, true);
187
188 //txtThueNhap.Text = CauHinhHeThong.Format_SoDeHienThi(CauHinhHeThong.Format_SoDeTinhToan(item["Thue"].ToString(), false), false);
189 //txtCkNhap.Text = CauHinhHeThong.Format_SoDeHienThi(CauHinhHeThong.Format_SoDeTinhToan(item["ChietKhauPhanTram"].ToString(), false), false);
190
191 txtTiLeLoiNhuan.Text = CauHinhHeThong.Format_SoDeHienThi(CauHinhHeThong.Format_SoDeTinhToan(item["TiLeLoiNhuan"].ToString(), false), false);
192 txtGiaBanLe.Text = CauHinhHeThong.Format_SoDeHienThi(CauHinhHeThong.Format_SoDeTinhToan(item["GiaBanLe"].ToString(), false), true);
193 txtGiaBanBuon.Text = CauHinhHeThong.Format_SoDeHienThi(CauHinhHeThong.Format_SoDeTinhToan(item["GiaBanBuon"].ToString(), false), true);
194 txtGiaKhuyenMai.Text = CauHinhHeThong.Format_SoDeHienThi(CauHinhHeThong.Format_SoDeTinhToan(item["GiaKhuyenMai"].ToString(), false), true);
195 txtCKSuat.Text = CauHinhHeThong.Format_SoDeHienThi(CauHinhHeThong.Format_SoDeTinhToan(item["ChietKhauPTBanHang"].ToString(), false), false);
196 cmbThueSuat.SelectedValue = item["ThueBanHang"].ToString();
197
198 //ComboBoxThue
199 //CauHinhHeThong.ComboBox_Thue(cmbThueSuat, item["ThueBanHang"].ToString());
200
201
202
203 }
204 * */
205 }
206
207 // cmbThueSuat.SelectedValue = "0";
208 }
209
210 private void btnLuuThietLap_Click(object sender, EventArgs e)
211 {
212 string _MaSanPham = string.Empty;
213 try
214 {
215 _MaSanPham = txtMaSanPham.Text.Trim();
216 }
217 catch { }
218
219 string _MaVietTat = string.Empty;
220 try
221 {
222 _MaVietTat = txtMaVietTat.Text.Trim();
223 }
224 catch { }
225
226 double _TiLeLoiNhuan = 0;
227 try
228 {
229 _TiLeLoiNhuan = CauHinhHeThong.Format_SoDeTinhToan(txtTiLeLoiNhuan.Text.Trim(),true);
230 }
231 catch { }
232
233 double _GiaBanLe = 0;
234 try
235 {
236 _GiaBanLe = CauHinhHeThong.Format_SoDeTinhToan(txtGiaBanLe.Text.Trim(),true);
237 }
238 catch { }
239
240 double _GiaBanBuon = 0;
241 try
242 {
243 _GiaBanBuon = CauHinhHeThong.Format_SoDeTinhToan(txtGiaBanBuon.Text.Trim(),true);
244 }
245 catch { }
246
247 double _GiaKhuyenMai = 0;
248 try
249 {
250 _GiaKhuyenMai = CauHinhHeThong.Format_SoDeTinhToan(txtGiaKhuyenMai.Text.Trim(),true);
251 }
252 catch { }
253
254 double _ThueBanHang = 0;
255 //try
256 //{
257 // _ThueBanHang = CauHinhHeThong.Format_SoDeTinhToan(cmbThueSuat.SelectedValue.ToString(),true);
258 //}
259 // catch { }
260
261 double _ChietKhauPTBanHang = 0;
262 //try
263 //{
264 // _ChietKhauPTBanHang = CauHinhHeThong.Format_SoDeTinhToan(txtCKSuat.Text,true);
265 //}
266 ///catch { }
267
268 //Controllers.KhoCtrl.UpdateKho_ThietLapGia(_getIdKho, _MaVietTat, _TiLeLoiNhuan, _GiaBanLe, _GiaBanBuon, _GiaKhuyenMai, _ThueBanHang, _ChietKhauPTBanHang);
269 Controllers.KhoCtrl.UpdateKho_ThietLapGiaBy_MaSanPham_MaVietTat(0, _MaSanPham, _MaVietTat, _TiLeLoiNhuan, _GiaBanLe, _GiaBanBuon, _GiaKhuyenMai, _ThueBanHang, _ChietKhauPTBanHang);
270 this.Close();
271 }
272
273 private void txtGiaNhap_KeyPress(object sender, KeyPressEventArgs e)
274 {
275 CauHinhHeThong.NhapSoTrongTextBox(sender, e);
276 }
277
278 private void txtThueNhap_KeyPress(object sender, KeyPressEventArgs e)
279 {
280 CauHinhHeThong.NhapSoTrongTextBox(sender, e);
281 }
282
283 private void txtCkNhap_KeyPress(object sender, KeyPressEventArgs e)
284 {
285 CauHinhHeThong.NhapSoTrongTextBox(sender, e);
286 }
287
288 private void txtTiLeLoiNhuan_KeyPress(object sender, KeyPressEventArgs e)
289 {
290 CauHinhHeThong.NhapSoTrongTextBox(sender, e);
291 }
292
293 private void txtGiaBanLe_KeyPress(object sender, KeyPressEventArgs e)
294 {
295 CauHinhHeThong.NhapSoTrongTextBox(sender, e);
296 }
297
298 private void txtGiaBanBuon_KeyPress(object sender, KeyPressEventArgs e)
299 {
300 CauHinhHeThong.NhapSoTrongTextBox(sender, e);
301 }
302
303 private void txtGiaKhuyenMai_KeyPress(object sender, KeyPressEventArgs e)
304 {
305 CauHinhHeThong.NhapSoTrongTextBox(sender, e);
306 }
307
308 private void txtCKSuat_KeyPress(object sender, KeyPressEventArgs e)
309 {
310 CauHinhHeThong.NhapSoTrongTextBox(sender, e);
311 }
312
313 private void txtGiaBanLe_TextChanged(object sender, EventArgs e)
314 {
315 if (txtClickGiaBanLe == false) { return; }
316
317 //if (loadlandau == true) { return; }
318
319 try
320 {
321 string value = txtGiaBanLe.Text.Replace(CauHinhHeThong.PHAN_CACH_HANG_NGHIN, "");
322 ulong ul = 0;
323
324 if (ulong.TryParse(value, out ul))
325 {
326 txtGiaBanLe.TextChanged -= txtGiaBanLe_TextChanged;
327
328 if (txtGiaBanLe.Text.StartsWith("0"))
329 {
330 txtGiaBanLe.Text = ul.ToString();
331 }
332 else
333 {
334 txtGiaBanLe.Text = CauHinhHeThong.DoFormat_NhapSoTrongText(value);
335 }
336
337
338 txtGiaBanLe.SelectionStart = txtGiaBanLe.Text.Length;
339 txtGiaBanLe.TextChanged += txtGiaBanLe_TextChanged;
340 }
341 else
342 {
343 if (txtGiaBanLe.Text.StartsWith(CauHinhHeThong.DAU_PHAY))
344 {
345 txtGiaBanLe.TextChanged -= txtGiaBanLe_TextChanged;
346 txtGiaBanLe.Text = "0" + txtGiaBanLe.Text;
347 txtGiaBanLe.SelectionStart = txtGiaBanLe.Text.Length;
348 txtGiaBanLe.TextChanged += txtGiaBanLe_TextChanged;
349 }
350 }
351
352 //tinh ti le loi nhuan va gia ban le
353 this.GaiBanLeHoacTiLeLoiNhuan(false);
354
355 }
356 catch
357 {
358 }
359 }
360
361 private void txtTiLeLoiNhuan_TextChanged(object sender, EventArgs e)
362 {
363 if (txtClickTiLeLoiNhuan == false) { return; }
364
365 if (loadlandau == true) { return; }
366
367 try
368 {
369 string value = txtTiLeLoiNhuan.Text.Replace(CauHinhHeThong.PHAN_CACH_HANG_NGHIN, "");
370 ulong ul = 0;
371
372 if (ulong.TryParse(value, out ul))
373 {
374 txtTiLeLoiNhuan.TextChanged -= txtTiLeLoiNhuan_TextChanged;
375
376 if (txtTiLeLoiNhuan.Text.StartsWith("0"))
377 {
378 txtTiLeLoiNhuan.Text = ul.ToString();
379 }
380 else
381 {
382 txtTiLeLoiNhuan.Text = CauHinhHeThong.DoFormat_NhapSoTrongText(value);
383 }
384
385
386 txtTiLeLoiNhuan.SelectionStart = txtTiLeLoiNhuan.Text.Length;
387 txtTiLeLoiNhuan.TextChanged += txtTiLeLoiNhuan_TextChanged;
388 }
389 else
390 {
391 if (txtTiLeLoiNhuan.Text.StartsWith(CauHinhHeThong.DAU_PHAY))
392 {
393 txtTiLeLoiNhuan.TextChanged -= txtTiLeLoiNhuan_TextChanged;
394 txtTiLeLoiNhuan.Text = "0" + txtTiLeLoiNhuan.Text;
395 txtTiLeLoiNhuan.SelectionStart = txtTiLeLoiNhuan.Text.Length;
396 txtTiLeLoiNhuan.TextChanged += txtTiLeLoiNhuan_TextChanged;
397 }
398 }
399
400 //tinh ti le loi nhuan va gia ban le
401 this.GaiBanLeHoacTiLeLoiNhuan(true);
402
403 }
404 catch
405 {
406 }
407 }
408
409 private void txtTiLeLoiNhuan_Click(object sender, EventArgs e)
410 {
411 txtClickTiLeLoiNhuan = true;
412 txtClickGiaBanLe = false;
413
414 loadlandau = false;
415 }
416
417 private void txtTiLeLoiNhuan_MouseCaptureChanged(object sender, EventArgs e)
418 {
419 txtClickTiLeLoiNhuan = true;
420 txtClickGiaBanLe = false;
421
422 loadlandau = false;
423 }
424
425 private void txtGiaBanLe_Click(object sender, EventArgs e)
426 {
427 txtClickTiLeLoiNhuan = false;
428 txtClickGiaBanLe = true;
429
430 loadlandau = false;
431 }
432
433 private void txtGiaBanLe_MouseCaptureChanged(object sender, EventArgs e)
434 {
435 txtClickTiLeLoiNhuan = false;
436 txtClickGiaBanLe = true;
437
438 loadlandau = false;
439 }
440
441 private void txtGiaBanBuon_TextChanged(object sender, EventArgs e)
442 {
443 if (loadlandau == true) { return; }
444
445 try
446 {
447 string value = txtGiaBanBuon.Text.Replace(CauHinhHeThong.PHAN_CACH_HANG_NGHIN, "");
448 ulong ul = 0;
449
450 if (ulong.TryParse(value, out ul))
451 {
452 txtGiaBanBuon.TextChanged -= txtGiaBanBuon_TextChanged;
453
454 if (txtGiaBanBuon.Text.StartsWith("0"))
455 {
456 txtGiaBanBuon.Text = ul.ToString();
457 }
458 else
459 {
460 txtGiaBanBuon.Text = CauHinhHeThong.DoFormat_NhapSoTrongText(value);
461 }
462
463
464 txtGiaBanBuon.SelectionStart = txtGiaBanBuon.Text.Length;
465 txtGiaBanBuon.TextChanged += txtGiaBanBuon_TextChanged;
466 }
467 else
468 {
469 if (txtGiaBanBuon.Text.StartsWith(CauHinhHeThong.DAU_PHAY))
470 {
471 txtGiaBanBuon.TextChanged -= txtGiaBanBuon_TextChanged;
472 txtGiaBanBuon.Text = "0" + txtGiaBanBuon.Text;
473 txtGiaBanBuon.SelectionStart = txtGiaBanBuon.Text.Length;
474 txtGiaBanBuon.TextChanged += txtGiaBanBuon_TextChanged;
475 }
476 }
477
478
479 }
480 catch
481 {
482 }
483 }
484
485 private void txtGiaKhuyenMai_TextChanged(object sender, EventArgs e)
486 {
487 if (loadlandau == true) { return; }
488
489 try
490 {
491 string value = txtGiaKhuyenMai.Text.Replace(CauHinhHeThong.PHAN_CACH_HANG_NGHIN, "");
492 ulong ul = 0;
493
494 if (ulong.TryParse(value, out ul))
495 {
496 txtGiaKhuyenMai.TextChanged -= txtGiaKhuyenMai_TextChanged;
497
498 if (txtGiaKhuyenMai.Text.StartsWith("0"))
499 {
500 txtGiaKhuyenMai.Text = ul.ToString();
501 }
502 else
503 {
504 txtGiaKhuyenMai.Text = CauHinhHeThong.DoFormat_NhapSoTrongText(value);
505 }
506
507
508 txtGiaKhuyenMai.SelectionStart = txtGiaKhuyenMai.Text.Length;
509 txtGiaKhuyenMai.TextChanged += txtGiaKhuyenMai_TextChanged;
510 }
511 else
512 {
513 if (txtGiaKhuyenMai.Text.StartsWith(CauHinhHeThong.DAU_PHAY))
514 {
515 txtGiaKhuyenMai.TextChanged -= txtGiaKhuyenMai_TextChanged;
516 txtGiaKhuyenMai.Text = "0" + txtGiaKhuyenMai.Text;
517 txtGiaKhuyenMai.SelectionStart = txtGiaKhuyenMai.Text.Length;
518 txtGiaKhuyenMai.TextChanged += txtGiaKhuyenMai_TextChanged;
519 }
520 }
521
522
523 }
524 catch
525 {
526 }
527 }
528
529 /*
530 private void txtCKSuat_TextChanged(object sender, EventArgs e)
531 {
532 if (loadlandau == true) { return; }
533
534 try
535 {
536 string value = txtCKSuat.Text.Replace(CauHinhHeThong.PHAN_CACH_HANG_NGHIN, "");
537 ulong ul = 0;
538
539 if (ulong.TryParse(value, out ul))
540 {
541 txtCKSuat.TextChanged -= txtCKSuat_TextChanged;
542
543 if (txtCKSuat.Text.StartsWith("0"))
544 {
545 txtCKSuat.Text = ul.ToString();
546 }
547 else
548 {
549 txtCKSuat.Text = CauHinhHeThong.DoFormat_NhapSoTrongText(value);
550 }
551
552
553 txtCKSuat.SelectionStart = txtCKSuat.Text.Length;
554 txtCKSuat.TextChanged += txtCKSuat_TextChanged;
555 }
556 else
557 {
558 if (txtCKSuat.Text.StartsWith(CauHinhHeThong.DAU_PHAY))
559 {
560 txtCKSuat.TextChanged -= txtCKSuat_TextChanged;
561 txtCKSuat.Text = "0" + txtCKSuat.Text;
562 txtCKSuat.SelectionStart = txtCKSuat.Text.Length;
563 txtCKSuat.TextChanged += txtCKSuat_TextChanged;
564 }
565 }
566 }
567 catch
568 {
569 }
570 }
571 */
572
573 private void txtGiaBanBuon_Click(object sender, EventArgs e)
574 {
575 loadlandau = false;
576 }
577
578 private void txtGiaBanBuon_MouseCaptureChanged(object sender, EventArgs e)
579 {
580 loadlandau = false;
581 }
582
583 private void txtGiaKhuyenMai_Click(object sender, EventArgs e)
584 {
585 loadlandau = false;
586 }
587
588 private void txtGiaKhuyenMai_MouseCaptureChanged(object sender, EventArgs e)
589 {
590 loadlandau = false;
591 }
592
593 private void txtCKSuat_Click(object sender, EventArgs e)
594 {
595 loadlandau = false;
596 }
597
598 private void txtCKSuat_MouseCaptureChanged(object sender, EventArgs e)
599 {
600 loadlandau = false;
601 }
602
603 private void GaiBanLeHoacTiLeLoiNhuan(bool txtChangedOTiLeLoiNhuan = true)
604 {
605
606 //tinh gia ban le
607 double gianhap = 0;
608 //double thuenhap = 0;
609 //double cknhap = 0;
610
611 gianhap = CauHinhHeThong.Format_SoDeTinhToan(txtGiaNhap.Text.Trim(),true);
612 //gianhap = CauHinhHeThong.Format_SoDeTinhToan(txtGiaNhap.Text, true);
613 //thuenhap = CauHinhHeThong.Format_SoDeTinhToan(txtThueNhap.Text,true);
614 //cknhap = CauHinhHeThong.Format_SoDeTinhToan(txtCkNhap.Text,true);
615
616 //double gianhap_CoThueVaCk = 0;
617 //gianhap_CoThueVaCk = gianhap + (gianhap * thuenhap / 100) - (gianhap * cknhap / 100);
618
619 double tienlai = 0;
620 double giabanle = 0;
621 double tileloinhuan = 0;
622
623 if (txtChangedOTiLeLoiNhuan == true)
624 {
625 tileloinhuan = CauHinhHeThong.Format_SoDeTinhToan(txtTiLeLoiNhuan.Text,true);
626
627 tienlai = gianhap * tileloinhuan / 100;
628
629 giabanle = tienlai + gianhap;
630
631 txtGiaBanLe.Text = CauHinhHeThong.Format_SoDeHienThi(giabanle, true);
632 }
633 else
634 {
635 giabanle = CauHinhHeThong.Format_SoDeTinhToan(txtGiaBanLe.Text,true);
636
637 tileloinhuan = ((giabanle - gianhap) / gianhap) * 100;
638
639 txtTiLeLoiNhuan.Text = CauHinhHeThong.Format_SoDeHienThi(tileloinhuan, false);
640 }
641
642
643
644
645
646
647
648 //double giabanlecolai = 0;
649 //giabanlecolai = tienlaibanra + gianhap_CoThueVaCk;
650
651 //txtGiaBanLe.Text = CauHinhHeThong.Format_SoDeHienThi(giabanlecolai, true);
652 }
653
654 private void btnTiep_Click(object sender, EventArgs e)
655 {
656
657 }
658
659 private void btnSau_Click(object sender, EventArgs e)
660 {
661
662 }
663
664 /*
665 private void HienThiDanhSachGiaNhap()
666 {
667 dgvDsachGiaNhap.Rows.Clear();
668 //Ẩn cột đầu tiên
669 dgvDsachGiaNhap.RowHeadersVisible = false;
670 //-https://stackoverflow.com/questions/17404969/right-align-a-column-in-datagridview-doesnt-work
671 this.dgvDsachGiaNhap.Columns["STT"].HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
672 this.dgvDsachGiaNhap.Columns["STT"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
673 //this.dgvDanhSachNhapHang.Columns["STT"].SortMode = DataGridViewColumnSortMode.NotSortable;
674
675 DataTable dtDsGia = new DataTable();
676
677 dtDsGia = Controllers.KhoCtrl.FillDataSet_getKho_GetSCac_SP_TonKho_ByMaSanPham_Search(_getMaVietTat, _pageSize, _pageIndex).Tables[0];
678
679 if (dtDsGia.Rows.Count > 0)
680 {
681 _tongSoBanGhi = Int32.Parse(dtDsGia.Rows[0]["TongSoBanGhi"].ToString());
682
683 double giaNhap = 0;
684 double thueNhap = 0;
685 double chietKhauNhap = 0;
686
687 float soluongNhap = 0;
688 //float soLuongTonKho = 0;
689 //float soLuongDaBan = 0;
690
691 double giaNhapThue_Ck = 0;
692
693 foreach (DataRow item in dtDsGia.Rows)
694 {
695 _stt += 1;
696 int nthue = dgvDsachGiaNhap.Rows.Add();
697
698 dgvDsachGiaNhap.Rows[nthue].Cells["IdKho"].Value = item["IdKho"].ToString();
699
700 dgvDsachGiaNhap.Rows[nthue].Cells["STT"].Value = _stt.ToString();
701
702 giaNhap = CauHinhHeThong.Format_SoDeTinhToan(item["GiaNhap"].ToString(), false);
703 chietKhauNhap = CauHinhHeThong.Format_SoDeTinhToan(item["ChietKhauPhanTram"].ToString(), false);
704 thueNhap = CauHinhHeThong.Format_SoDeTinhToan(item["Thue"].ToString(), false);
705
706 giaNhapThue_Ck = giaNhap - giaNhap * chietKhauNhap / 100 + giaNhap * thueNhap / 100;
707
708 //soLuongDaBan =(float)CauHinhHeThong.Format_SoDeTinhToan(item["SoLuongDaBan"].ToString(), false);
709 soluongNhap = (float)CauHinhHeThong.Format_SoDeTinhToan(item["SoLuong"].ToString(), false);
710
711 //soLuongTonKho = soluongNhap - soLuongDaBan;
712
713 dgvDsachGiaNhap.Rows[nthue].Cells["SoLuong"].Value = CauHinhHeThong.Format_SoDeHienThi(soluongNhap, false);
714
715 dgvDsachGiaNhap.Rows[nthue].Cells["GiaNhapTb"].Value = CauHinhHeThong.Format_SoDeHienThi(giaNhapThue_Ck, true);
716 }
717 }
718 }
719 * */
720 }
721 }